/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RoleFrame.java
 *
 * Created on 2011-8-22, 20:30:57
 */
package com.securitytrace.popupwindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFrame;

import com.securitytrace.client.ManagerClient;

/**
 *
 * @author Administrator
 */
public class RoleWindow extends JDialog {

	private static final long serialVersionUID = -7307997083838554616L;
	private ManagerClient managerClient;
	/** Creates new form RoleFrame */
    public RoleWindow(JFrame frame,boolean flag) {
    	super(frame,flag);
    	managerClient = (ManagerClient) frame;
    	initComponents();
    	int parentWidth = (int)managerClient.getLocation().getX();
    	int parentHight = (int)managerClient.getLocation().getY();
    	int width = this.getWidth();
    	int hight = this.getHeight();
    	this.setLocation(parentWidth+width/2, parentHight+hight/2);
    	init();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rolePanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        roleTextField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        roleTextArea = new javax.swing.JTextArea();
        roleSubmitButton = new javax.swing.JButton();
        roleResetButton = new javax.swing.JButton();

       // setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setText("角色名称：");
        jLabel2.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel2.setText("角  色  信  息");
        jLabel3.setText("角色描述：");
        roleTextArea.setColumns(20);
        roleTextArea.setLineWrap(true);
        roleTextArea.setRows(5);
        jScrollPane1.setViewportView(roleTextArea);
        roleSubmitButton.setText("确  定");
        roleResetButton.setText("取  消");

        javax.swing.GroupLayout rolePanelLayout = new javax.swing.GroupLayout(rolePanel);
        rolePanel.setLayout(rolePanelLayout);
        rolePanelLayout.setHorizontalGroup(
            rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rolePanelLayout.createSequentialGroup()
                .addGroup(rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(rolePanelLayout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addGroup(rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(rolePanelLayout.createSequentialGroup()
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(roleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 204, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(rolePanelLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(rolePanelLayout.createSequentialGroup()
                        .addGap(105, 105, 105)
                        .addComponent(roleSubmitButton)
                        .addGap(61, 61, 61)
                        .addComponent(roleResetButton))
                    .addGroup(rolePanelLayout.createSequentialGroup()
                        .addGap(130, 130, 130)
                        .addComponent(jLabel2)))
                .addContainerGap(71, Short.MAX_VALUE))
        );

        rolePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel3});

        rolePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane1, roleTextField});

        rolePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {roleResetButton, roleSubmitButton});

        rolePanelLayout.setVerticalGroup(
            rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rolePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(roleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(rolePanelLayout.createSequentialGroup()
                        .addGap(56, 56, 56)
                        .addComponent(jLabel3))
                    .addGroup(rolePanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)
                .addGroup(rolePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(roleResetButton)
                    .addComponent(roleSubmitButton))
                .addGap(25, 25, 25))
        );

        rolePanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel3, roleTextField});

        rolePanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {roleResetButton, roleSubmitButton});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rolePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(rolePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    void init() {
    	roleResetButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				RoleWindow frame = getInstance();
				frame.dispose();
			}
		});
    }
    
    public RoleWindow getInstance() {
    	return this;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel rolePanel;
    private javax.swing.JButton roleResetButton;
    private javax.swing.JButton roleSubmitButton;
    private javax.swing.JTextArea roleTextArea;
    private javax.swing.JTextField roleTextField;
    // End of variables declaration//GEN-END:variables
	public ManagerClient getManagerClient() {
		return managerClient;
	}
	public javax.swing.JTextArea getRoleTextArea() {
		return roleTextArea;
	}
	public void setRoleTextArea(javax.swing.JTextArea roleTextArea) {
		this.roleTextArea = roleTextArea;
	}
	public javax.swing.JTextField getRoleTextField() {
		return roleTextField;
	}
	public void setRoleTextField(javax.swing.JTextField roleTextField) {
		this.roleTextField = roleTextField;
	}
	public void setRoleSubmitButton(ActionListener listener) {
		this.roleSubmitButton.addActionListener(listener);
	}
}
